import { getMainGit, getVipHomeList, getHotsRecommendList, getTourShowList, getRecommendList } from '../../api/request'
export default {
    namespaced: true,
    state: {
        gitData: null,
        navList: [],
        classList: [],
        bottomList: [],
        vipList: [],
        hotsShowList: [],
        tourShowList: [],
        recommendList: [],
        showBtoNav: true
    },
    getters: {
        // getTourCityList(state) {

        //     return
        // }
    },
    mutations: {
        //主页数据 底部导航 菜单栏 轮播图 git动画
        getMainGit(state, data) {
            state.gitData = data
        },
        getSlideList(state, data) {
            state.navList = data
        },
        getClassList(state, data) {
            state.classList = data
        },
        getBottomList(state, data) {
            state.bottomList = data
        },
        //vip相关数据
        getVipHomeList(state, data) {
            state.vipList = data
        },
        //热门演出
        getHotsRecommendList(state, data) {
            state.hotsShowList = data
        },
        //巡回演出列表
        getTourShowList(state, data) {
            state.tourShowList = data
        },
        //推荐列表
        getRecommendList(state, data) {
            if (state.recommendList.length > 0) {
                data.forEach((v) => {
                    state.recommendList.push(v)
                })

            } else {
                state.recommendList = data
            }

        },
        //显示与隐藏
        getShowBtoNav(state, data) {
            state.showBtoNav = data
        }

    },
    actions: {
        async setMainGit({ commit }) {
            let ret = await getMainGit()
            commit('getSlideList', ret.data.data.slide_list)
            commit('getMainGit', ret.data.data.ad_list.float_ad[0])

            commit('getClassList', ret.data.data.classify_list)
            commit('getBottomList', ret.data.data.bottom_list)

        },
        async setVipHomeList({ commit }) {
            let ret = await getVipHomeList()

            commit('getVipHomeList', ret.data.data.allList)

        },
        async setHotsRecommendList({ commit }) {
            let ret = await getHotsRecommendList()
            commit('getHotsRecommendList', ret.data.data.hots_show_list)
        },
        async setTourShowList({ commit }) {
            let ret = await getTourShowList()
            commit('getTourShowList', ret.data.data.list)
        },
        async setRecommendList({ commit }, page = 2) {
            let ret = await getRecommendList(page)
            commit('getRecommendList', ret.data.data.list)
        },
        setShowBtoNav({ commit }, show) {
            commit('getShowBtoNav', show)
        }
    }
}